// components/playlist/playlist.js
Component({
  /**
   * 组件的属性列表
   */
  properties: {
    item: Object
  },

  observers: {
    ["item.playCount"](val) {
      // this._setCount(val);
      this.setData({
        count: this._setCount(val, 2)
      })
    }
  },

  externalClasses: [
    "iconfont",
    "icon-pinglun"
  ],

  /**
   * 组件的初始数据
   */
  data: {
    count: 0
  },

  /**
   * 组件的方法列表
   */
  methods: {
    // 设置数字
    _setCount(num, point) {
      const str = num.toString().split(".")[0];
      const len = str.length;
      // console.log(len);
      if (len < 6) {
        return str;
      } else if (len >= 6 && len <= 8) {
        let decimal = str.substring(len - 4, len - 4 + point);
        return parseFloat(parseInt(num / 10000) + "." + decimal) + "万";
      } else if (len > 8) {
        let decimal = str.substring(len - 8, len - 8 + point);
        return parseFloat(parseInt(num / 100000000) + "." + decimal) + "亿";
      }
    }
  }
})